"""
LLM模型配置表
"""
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, JSON
from sqlalchemy.sql import func
from app.models.base import Base


class LLMModel(Base):
    __tablename__ = "llm_models"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(100), unique=True, nullable=False, comment="模型名称")
    provider = Column(String(50), nullable=False, comment="提供商")
    model_name = Column(String(100), nullable=False, comment="实际模型名称")
    api_key = Column(String(500), nullable=True, comment="API密钥")
    base_url = Column(String(500), nullable=True, comment="API基础URL")
    max_tokens = Column(Integer, default=4000, comment="最大token数")
    temperature = Column(JSON, default={"default": 0.7, "min": 0, "max": 2}, comment="温度参数")
    is_active = Column(Boolean, default=True, comment="是否启用")
    config = Column(JSON, default={}, comment="额外配置")
    description = Column(Text, nullable=True, comment="描述")
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())